<%--
  Created by IntelliJ IDEA.
  User: yang
  Date: 7/20/20
  Time: 19:21
  To change this template use File | Settings | File Templates.
--%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@page contentType="text/html; charset=UTF-8" language="java" errorPage="error.jsp" %>

<html>
<head>
    <title>登陆</title>
</head>
<body>


<!DOCTYPE html>
<html lang=en>
<head>
    <meta charset=UTF-8>
    <title>登陆</title>
    <link rel="stylesheet" href="${theProjectName}/css/login.css">
    <!--  链接样式表   -->
    <script src=${theProjectName}/js/jquery.min.js></script>
    <!-- 导入 jquery    -->
    <script src=${theProjectName}/js/login.js></script>
    <!--  判断是否为空  -->
    <script>
        $(function () {
            // TODO 页面加载完毕后执行
            $("input[name='tid']").bind("blur", function () {
                // TODO blur 焦点从 tid 输入框移出
                // 获取 输入框的值
                let sname = $("input[name='tid']").val();
                // 获取 对象
                let xgr = new XMLHttpRequest()
                // 设置请求方式 地址
                xgr.open("POST", "${theProjectName}" + "/ajax/userNameExists");
                // post 设置请求头 Context-Type 模拟表单提交
                xgr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                // 设置参数
                xgr.send("sname=" + sname);
                xgr.onreadystatechange = function () {
                    // TODO 判断响应的状态
                    if (xgr.readyState === 4 && xgr.status === 200) {
                        // 赋值
                        $("#loginMessage").text(xgr.responseText);
                    }
                }
                // 设置显示
                $("#loginMessage").css("display", "block");
            });
        });
    </script>
</head>
<body>

<h1 align="center" style="color: red">
    ${user==false?"登陆失败！！！":""}
</h1>
<h1 align="center">老师 登陆</h1>
<form action="${theProjectName}/login" method="post">
    <table>
        <tr>
            <th>用户名:</th>
            <td><label>
                <input type="text" name="tid">
            </label></td>
        </tr>
        <tr>
            <td colspan="2"><p id="loginMessage"></p></td>
        </tr>
        <tr>
            <th>密 码：</th>
            <td>
                <label>
                    <input type="password" name="tpwd">
                </label>
            </td>
        </tr>
        <tr>
            <th colspan=2>
                <input type="reset" value="重新填写">
                <input type="submit" value="登陆">
            </th>
        </tr>
    </table>

</form>


</body>
</html>

</body>
</html>
